import Vue from 'vue'
import VueRouter from 'vue-router'
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject){
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)



const routes = [

  //这种写法叫做路由懒加载
  {
    path: '/login',
    component: () => import('@/views/login/login'),
    meta: {
      title: `登录`
    }
  },
  {
    path: '/',
    redirect: '/index',
    name: 'layout',
    component: () => import('@/components/layout'),
    children: [
      {
        path: '/index',
        name: 'Index',
        component: () => import('@/views/index/index'),
        meta: {
          title: `欢迎页面`
        }
      },
      {
        path: '/user',
        name: 'User',
        component: () => import('@/views/system/user/list'),
        meta: {
          title: `用户管理`
        }
      },
      {
        path: '/menu',
        name: 'Menu',
        component: () => import('@/views/system/menu/list'),
        meta: {
          title: `菜单管理`
        }
      },
      {
        path: '/role',
        name: 'Role',
        component: () => import('@/views/system/role/list'),
        meta: {
          title: `角色管理`
        }
      },
      {
        path: '/notice',
        name: 'Notice',
        component: () => import('@/views/system/notice/list'),
        meta: {
          title: `公告管理`
        }
      },


      {
        path: '/icon',
        name: 'Icon',
        component: () => import('@/views/other/icon/index'),
        meta: {
          title: `图标库`
        }
      },
      {
        path: '/sql',
        name: 'Sql',
        component: () => import('@/views/other/sql/index'),
        meta: {
          title: `SQL监控`
        }
      },
      {
        path: '/swagger',
        name: 'Swagger',
        component: () => import('@/views/other/swagger/index'),
        meta: {
          title: `swagger文档`
        }
      },
      {
        path: '/umsg',
        name: 'Umsg',
        component: () => import('@/views/user/index'),
        meta: {
          title: `个人中心`
        }
      },
      {
        path: '/coding',
        name: 'Coding',
        component: () => import('@/views/other/coding/coding'),
        meta: {
          title: `代码生成`
        }
       },

        {
        path: '/test06',
        name: 'Test06',
        component: () => import('@/views/test06'),
        meta: {title: `t6`}
        },

        {
        path: '/test05',
        name: 'Test05',
        component: () => import('@/views/test05'),
        meta: {title: `t5`}
        },

        {
        path: '/test04',
        name: 'Test04',
        component: () => import('@/views/test04'),
        meta: {title: `t4`}
        },

        {
        path: '/test03',
        name: 'Test03',
        component: () => import('@/views/test03'),
        meta: {title: `t3`}
        },

        {
        path: '/test02',
        name: 'Test02',
        component: () => import('@/views/test02'),
        meta: {title: `t2`}
        },
        {
        path: '/test01',
        name: 'Test01',
        component: () => import('@/views/test01'),
        meta: {title: `t1`}
        },
      //{
      // path: '/record',
      // name: 'Record',
      // component: () => import('@/views/record'),
      // meta: {title: `记录`}
      // },

    ]
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})
export default router
